<template>
	<view>
		<myhead left="1"></myhead>
		<view class="tit">添加银行卡</view>
		<view class="inputList">
		    <view class="title">姓名</view>
		    <input placeholder="请输入银行卡姓名" v-model="cardName"></input>
		</view>
		<view class="inputList">
		    <view class="title">银行卡号</view>
		    <input placeholder="请输入银行卡号" v-model="cardNum"></input>
		</view>
		<view class="inputList">
		    <view class="title">开户银行</view>
		    <input placeholder="请输入开户银行" v-model="cardBankName"></input>
		</view>
		<view class="btn" @tap="btn">确定</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				cardName:null,
				cardNum:null,
				cardBankName:null
			}
		},
		methods: {
			btn:function(){
				if(!this.cardName){
					uni.showToast({
					  title: '请输入银行卡姓名',
					  icon: 'none'
					});
					return false
				}
				if(!this.cardNum){
					uni.showToast({
					  title: '请输入银行卡号',
					  icon: 'none'
					});
					return false
				}
				if(!this.cardBankName){
					uni.showToast({
					  title: '请输入开户银行',
					  icon: 'none'
					});
					return false
				}
				uni.showLoading({
				    title: '加载中'
				});
				http.post('/api/user/addBank',{bankUserName:this.cardName,bankName:this.cardBankName,bankNo:this.cardNum}).then(res => {
					uni.showToast({
					  title: res.message,
					  icon: 'none',
					  duration:1000
					});
					if (res.code == 200) {
						setTimeout(function () {
						    uni.navigateBack({
						        delta: 1
						    });
						}, 1000);
					}
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style>
	.tit{
		padding: 8vw;
		font-size: 7vw;
		color: #333333;
	}
	.inputList{
		padding: 0 8vw;
		margin-bottom: 6vw;
	}
	.inputList .title{
		margin-bottom: 2vw;
		font-size: 3.6vw;
		color: #999999;
	}
	.inputList input{
		height: 12vw;
		line-height: 12vw;
		border-bottom: 1px solid #F2F2F2;
	}
	.btn{
		width: 84%;
		padding: 4vw 0;
		font-size: 3.5vw;
		border-radius: 1.8vw;
		background-image: linear-gradient(45deg, #24EBA9, #10C7B2);
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 10vw;
	}
</style>
